package uk.ac.staffs.student.autopilot.views;

//import uk.ac.staffs.student.autopilot.AutoPilotApp;
import uk.ac.staffs.student.autopilot.packet.*;
import uk.ac.staffs.student.autopilot.AutoPilotInterface;
import uk.ac.staffs.student.autopilot.SerialPortStatus;
import gnu.io.SerialPortEventListener;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.apache.log4j.Logger;


/**
 *
 * @author peter
 */


public class APHciSwingPanelRv2 extends JPanel implements Observer, ActionListener {

    /**
     * Creates new form Autopilot_HCI_Panel2
     */
	
    public static Logger logger = Logger.getLogger(APHciSwingPanelRv2.class);
    private TelemetryGyrosPacket tgp = null;
    private TelemetryAccelsPacket tap = null;
    private GpsPacket gpsp = null;
    private MagPacket mp = null;
    private RtfPacket rtfp = null;
    private SerialPortStatus sps = null;
    private AutoPilotInterface controller;
    
    public APHciSwingPanelRv2(AutoPilotInterface controller) {
        this.controller = controller;
        initComponents();
    }


    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
 // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        controlPanel = new javax.swing.JPanel();
        controlLabel = new javax.swing.JLabel();
        mode1Panel = new javax.swing.JPanel();
        setMode1Btn(new javax.swing.JButton());
        mode1SentTxtF = new javax.swing.JTextField();
        mode1Label = new javax.swing.JLabel();
        mode1RecTxtF = new javax.swing.JTextField();
        mode1SentLabel = new javax.swing.JLabel();
        mode1RecLabel = new javax.swing.JLabel();
        mode2Panel = new javax.swing.JPanel();
        mode2Btn = new javax.swing.JButton();
        mode2RecLabel = new javax.swing.JLabel();
        mode2RecTxtF = new javax.swing.JTextField();
        mode2SentTxtF = new javax.swing.JTextField();
        mode2SentLabel = new javax.swing.JLabel();
        mode2Label = new javax.swing.JLabel();
        mode3Panel = new javax.swing.JPanel();
        mode3Btn = new javax.swing.JButton();
        mode3RecTxtF = new javax.swing.JTextField();
        mode3SentLabel = new javax.swing.JLabel();
        mode3RecLabel = new javax.swing.JLabel();
        mode3SentTxtF = new javax.swing.JTextField();
        mode3Label = new javax.swing.JLabel();
        mode4Panel = new javax.swing.JPanel();
        mode4Btn = new javax.swing.JButton();
        mode4RecLabel = new javax.swing.JLabel();
        mode4SentTxtF = new javax.swing.JTextField();
        mode4RecTxtF = new javax.swing.JTextField();
        mode4SentLabel = new javax.swing.JLabel();
        mode4Label = new javax.swing.JLabel();
        connectionsPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        baudLabel = new javax.swing.JLabel();
        portLabel = new javax.swing.JLabel();
        connLabel = new javax.swing.JLabel();
        baudTxtF = new javax.swing.JTextField();
        portTxtF = new javax.swing.JTextField();
        connectedTxtF = new javax.swing.JTextField();
        telemetryPanel = new javax.swing.JPanel();
        telemLabel = new javax.swing.JLabel();
        gyrosPanel = new javax.swing.JPanel();
        gyrosLabel = new javax.swing.JLabel();
        axisXTxtF = new javax.swing.JTextField();
        axisYTxtF = new javax.swing.JTextField();
        axisZTxtF = new javax.swing.JTextField();
        axisXLabel = new javax.swing.JLabel();
        axisYLabel = new javax.swing.JLabel();
        axisZLabel = new javax.swing.JLabel();
        accelsPanel = new javax.swing.JPanel();
        accelLabel = new javax.swing.JLabel();
        accelXLabel = new javax.swing.JLabel();
        accelTxtF = new javax.swing.JTextField();
        accelYLabel = new javax.swing.JLabel();
        accelYTxtF = new javax.swing.JTextField();
        accelZTxtF = new javax.swing.JTextField();
        accelZLabel = new javax.swing.JLabel();
        magPanel = new javax.swing.JPanel();
        MagLabel = new javax.swing.JLabel();
        magXLabel = new javax.swing.JLabel();
        magYLabel = new javax.swing.JLabel();
        magZLabel = new javax.swing.JLabel();
        magHeadLabel = new javax.swing.JLabel();
        magXTxtF = new javax.swing.JTextField();
        magYTxtF = new javax.swing.JTextField();
        magZTxtF = new javax.swing.JTextField();
        magHeadTxtF = new javax.swing.JTextField();
        gpsPanel = new javax.swing.JPanel();
        gpsLabel = new javax.swing.JLabel();
        gpsLongLabel = new javax.swing.JLabel();
        gpsLatLabel = new javax.swing.JLabel();
        gpsAltLabel = new javax.swing.JLabel();
        gpsGndSpLabel = new javax.swing.JLabel();
        gpsLongTxtF = new javax.swing.JTextField();
        gpsLatTxtF = new javax.swing.JTextField();
        gpsAltTxtF = new javax.swing.JTextField();
        gpsGndSpeedTxtF = new javax.swing.JTextField();
        gpsGndCourLabel = new javax.swing.JLabel();
        gpsNumSatLabel = new javax.swing.JLabel();
        gpsFixLabel = new javax.swing.JLabel();
        gpsTimeLabel = new javax.swing.JLabel();
        gpsGndCourTxtF = new javax.swing.JTextField();
        gpsNumSatTxtF = new javax.swing.JTextField();
        gpsFixTxtF = new javax.swing.JTextField();
        gpsTimeTxtF = new javax.swing.JTextField();
        exitButton = new javax.swing.JButton();
        

        controlPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        controlLabel.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        controlLabel.setText("Control Panel");

        mode1Panel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        getMode1Btn().setBackground(new java.awt.Color(255, 255, 0));
        getMode1Btn().setText("Mode 1");
        getMode1Btn().addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(final java.awt.event.ActionEvent evt) {
                // Method to create a packet and call the controller
                Mode1BtnActionPerformed(evt);
            }
        });
        
        // Keep logic for exit here simple action
        exitButton.addActionListener(new ActionListener() {
            
            @Override
            public void actionPerformed(ActionEvent e) {
                controller.exit();
                
            }
        });
        
        
        mode1SentTxtF.setBackground(new java.awt.Color(255, 0, 0));

        mode1Label.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        mode1Label.setText("Ready to Fly Mode");

        mode1RecTxtF.setBackground(new java.awt.Color(255, 0, 0));

        mode1SentLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        mode1SentLabel.setText("Sent:");

        mode1RecLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        mode1RecLabel.setText("Received:");

        javax.swing.GroupLayout mode1PanelLayout = new javax.swing.GroupLayout(mode1Panel);
        mode1Panel.setLayout(mode1PanelLayout);
        mode1PanelLayout.setHorizontalGroup(
            mode1PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mode1PanelLayout.createSequentialGroup()
                .addGroup(mode1PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mode1PanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(mode1Label))
                    .addGroup(mode1PanelLayout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addGroup(mode1PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(mode1PanelLayout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(getMode1Btn(), javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(mode1PanelLayout.createSequentialGroup()
                                .addGroup(mode1PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(mode1SentLabel)
                                    .addComponent(mode1RecLabel))
                                .addGap(10, 10, 10)
                                .addGroup(mode1PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(mode1RecTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(mode1SentTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        mode1PanelLayout.setVerticalGroup(
            mode1PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mode1PanelLayout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(mode1Label)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(mode1PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(mode1SentTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(mode1SentLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
                .addGroup(mode1PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(mode1RecTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(mode1RecLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(getMode1Btn())
                .addContainerGap())
        );

        mode2Panel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        mode2Btn.setBackground(new java.awt.Color(0, 255, 0));
        mode2Btn.setText("Mode 2");
        mode2Btn.setEnabled(false);

        mode2RecLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        mode2RecLabel.setText("Received:");

        mode2RecTxtF.setBackground(new java.awt.Color(255, 0, 0));

        mode2SentTxtF.setBackground(new java.awt.Color(255, 0, 0));

        mode2SentLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        mode2SentLabel.setText("Sent:");

        mode2Label.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        mode2Label.setText("Mission Ready Mode");

        javax.swing.GroupLayout mode2PanelLayout = new javax.swing.GroupLayout(mode2Panel);
        mode2Panel.setLayout(mode2PanelLayout);
        mode2PanelLayout.setHorizontalGroup(
            mode2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mode2PanelLayout.createSequentialGroup()
                .addGroup(mode2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mode2PanelLayout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addGroup(mode2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(mode2PanelLayout.createSequentialGroup()
                                .addGroup(mode2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(mode2SentLabel)
                                    .addComponent(mode2RecLabel))
                                .addGap(10, 10, 10)
                                .addGroup(mode2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(mode2RecTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(mode2SentTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(mode2Btn)))
                    .addGroup(mode2PanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(mode2Label)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        mode2PanelLayout.setVerticalGroup(
            mode2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mode2PanelLayout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(mode2Label)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(mode2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(mode2SentTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(mode2SentLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(mode2PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(mode2RecTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(mode2RecLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(mode2Btn)
                .addContainerGap())
        );

        mode3Panel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        mode3Btn.setBackground(new java.awt.Color(0, 0, 255));
        mode3Btn.setForeground(new java.awt.Color(255, 255, 255));
        mode3Btn.setText("Mode 3");
        mode3Btn.setEnabled(false);

        mode3RecTxtF.setBackground(new java.awt.Color(255, 0, 0));

        mode3SentLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        mode3SentLabel.setText("Sent:");

        mode3RecLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        mode3RecLabel.setText("Received:");

        mode3SentTxtF.setBackground(new java.awt.Color(255, 0, 0));

        mode3Label.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        mode3Label.setText("Mission Start Mode");

        javax.swing.GroupLayout mode3PanelLayout = new javax.swing.GroupLayout(mode3Panel);
        mode3Panel.setLayout(mode3PanelLayout);
        mode3PanelLayout.setHorizontalGroup(
            mode3PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mode3PanelLayout.createSequentialGroup()
                .addGroup(mode3PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mode3PanelLayout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addGroup(mode3PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(mode3PanelLayout.createSequentialGroup()
                                .addGroup(mode3PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(mode3SentLabel)
                                    .addComponent(mode3RecLabel))
                                .addGap(10, 10, 10)
                                .addGroup(mode3PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(mode3RecTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(mode3SentTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(mode3Btn)))
                    .addGroup(mode3PanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(mode3Label)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        mode3PanelLayout.setVerticalGroup(
            mode3PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mode3PanelLayout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(mode3Label)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(mode3PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(mode3SentTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(mode3SentLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(mode3PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(mode3RecTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(mode3RecLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(mode3Btn)
                .addContainerGap())
        );

        mode4Panel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        mode4Btn.setBackground(new java.awt.Color(255, 0, 0));
        mode4Btn.setForeground(new java.awt.Color(255, 255, 255));
        mode4Btn.setText("Mode 4");
        mode4Btn.setEnabled(false);

        mode4RecLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        mode4RecLabel.setText("Received:");

        mode4SentTxtF.setBackground(new java.awt.Color(255, 0, 0));

        mode4RecTxtF.setBackground(new java.awt.Color(255, 0, 0));

        mode4SentLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        mode4SentLabel.setText("Sent:");

        mode4Label.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        mode4Label.setText("Landing Mode");

        javax.swing.GroupLayout mode4PanelLayout = new javax.swing.GroupLayout(mode4Panel);
        mode4Panel.setLayout(mode4PanelLayout);
        mode4PanelLayout.setHorizontalGroup(
            mode4PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mode4PanelLayout.createSequentialGroup()
                .addGroup(mode4PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mode4PanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(mode4Label))
                    .addGroup(mode4PanelLayout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(mode4PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(mode4PanelLayout.createSequentialGroup()
                                .addGroup(mode4PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(mode4SentLabel)
                                    .addComponent(mode4RecLabel))
                                .addGap(10, 10, 10)
                                .addGroup(mode4PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(mode4RecTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(mode4SentTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(mode4Btn))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        mode4PanelLayout.setVerticalGroup(
            mode4PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mode4PanelLayout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(mode4Label)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(mode4PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(mode4SentTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(mode4SentLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(mode4PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(mode4RecTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(mode4RecLabel))
                .addGap(11, 11, 11)
                .addComponent(mode4Btn)
                .addContainerGap())
        );

        javax.swing.GroupLayout controlPanelLayout = new javax.swing.GroupLayout(controlPanel);
        controlPanel.setLayout(controlPanelLayout);
        controlPanelLayout.setHorizontalGroup(
            controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(controlPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(controlLabel)
                    .addGroup(controlPanelLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(mode1Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(mode2Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(mode3Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(mode4Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        controlPanelLayout.setVerticalGroup(
            controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(controlPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(controlLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(mode1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(mode2Panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(mode3Panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(mode4Panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        connectionsPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        jLabel1.setText("Connections");

        baudLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        baudLabel.setText("Baud Rate:");

        portLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        portLabel.setText("Port:");

        connLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        connLabel.setText("Connected:");

        baudTxtF.setEditable(false);

        portTxtF.setEditable(false);

        connectedTxtF.setBackground(new java.awt.Color(255, 0, 0));

        javax.swing.GroupLayout connectionsPanelLayout = new javax.swing.GroupLayout(connectionsPanel);
        connectionsPanel.setLayout(connectionsPanelLayout);
        connectionsPanelLayout.setHorizontalGroup(
            connectionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(connectionsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(connectionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(connectionsPanelLayout.createSequentialGroup()
                        .addGroup(connectionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(baudLabel)
                            .addComponent(portLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(connectionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(baudTxtF)
                            .addComponent(portTxtF)))
                    .addGroup(connectionsPanelLayout.createSequentialGroup()
                        .addGroup(connectionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addGroup(connectionsPanelLayout.createSequentialGroup()
                                .addComponent(connLabel)
                                .addGap(29, 29, 29)
                                .addComponent(connectedTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 27, Short.MAX_VALUE)))
                .addContainerGap())
        );
        connectionsPanelLayout.setVerticalGroup(
            connectionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(connectionsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(27, 27, 27)
                .addGroup(connectionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(baudLabel)
                    .addComponent(baudTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(connectionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(portLabel)
                    .addComponent(portTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(connectionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(connLabel)
                    .addComponent(connectedTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        telemetryPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        telemLabel.setFont(new java.awt.Font("Verdana", 1, 12)); // NOI18N
        telemLabel.setText("Telemetry Data");

        gyrosPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        gyrosLabel.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        gyrosLabel.setText("Gyro Data");

        axisXTxtF.setEditable(false);

        axisYTxtF.setEditable(false);

        axisZTxtF.setEditable(false);

        axisXLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        axisXLabel.setText("Axis X:");

        axisYLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        axisYLabel.setText("Axis Y:");

        axisZLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        axisZLabel.setText("Axis Z:");

        javax.swing.GroupLayout gyrosPanelLayout = new javax.swing.GroupLayout(gyrosPanel);
        gyrosPanel.setLayout(gyrosPanelLayout);
        gyrosPanelLayout.setHorizontalGroup(
            gyrosPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(gyrosPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(gyrosPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(gyrosLabel)
                    .addGroup(gyrosPanelLayout.createSequentialGroup()
                        .addGroup(gyrosPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(axisXLabel)
                            .addComponent(axisYLabel)
                            .addComponent(axisZLabel))
                        .addGap(18, 18, 18)
                        .addGroup(gyrosPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(axisYTxtF, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE)
                            .addComponent(axisXTxtF)
                            .addComponent(axisZTxtF))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        gyrosPanelLayout.setVerticalGroup(
            gyrosPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(gyrosPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(gyrosLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(gyrosPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(axisXTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(axisXLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(gyrosPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(axisYTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(axisYLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(gyrosPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(axisZLabel)
                    .addComponent(axisZTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        accelsPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        accelLabel.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        accelLabel.setText("Accellerometer Data");

        accelXLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        accelXLabel.setText("Accel X:");

        accelTxtF.setEditable(false);

        accelYLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        accelYLabel.setText("Accel Y:");

        accelYTxtF.setEditable(false);

        accelZTxtF.setEditable(false);

        accelZLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        accelZLabel.setText("Accel Z:");

        javax.swing.GroupLayout accelsPanelLayout = new javax.swing.GroupLayout(accelsPanel);
        accelsPanel.setLayout(accelsPanelLayout);
        accelsPanelLayout.setHorizontalGroup(
            accelsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(accelsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(accelsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(accelsPanelLayout.createSequentialGroup()
                        .addGroup(accelsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(accelXLabel, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(accelYLabel, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(accelZLabel, javax.swing.GroupLayout.Alignment.LEADING))
                        .addGap(18, 18, 18)
                        .addGroup(accelsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(accelTxtF, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(accelYTxtF, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(accelZTxtF, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(accelLabel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        accelsPanelLayout.setVerticalGroup(
            accelsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(accelsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(accelLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(accelsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(accelXLabel)
                    .addComponent(accelTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(accelsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(accelYLabel)
                    .addComponent(accelYTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(accelsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(accelZTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(accelZLabel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        magPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        MagLabel.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        MagLabel.setText("Magnetometer Data");

        magXLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        magXLabel.setText("Mag X:");

        magYLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        magYLabel.setText("Mag Y:");

        magZLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        magZLabel.setText("Mag Z:");

        magHeadLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        magHeadLabel.setText("Heading:");

        magXTxtF.setEditable(false);

        magYTxtF.setEditable(false);

        magZTxtF.setEditable(false);

        magHeadTxtF.setEditable(false);

        javax.swing.GroupLayout magPanelLayout = new javax.swing.GroupLayout(magPanel);
        magPanel.setLayout(magPanelLayout);
        magPanelLayout.setHorizontalGroup(
            magPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(magPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(magPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(MagLabel)
                    .addGroup(magPanelLayout.createSequentialGroup()
                        .addGroup(magPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(magXLabel)
                            .addComponent(magYLabel)
                            .addComponent(magZLabel)
                            .addComponent(magHeadLabel))
                        .addGap(23, 23, 23)
                        .addGroup(magPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(magZTxtF)
                            .addComponent(magYTxtF)
                            .addComponent(magHeadTxtF)
                            .addComponent(magXTxtF))))
                .addContainerGap())
        );
        magPanelLayout.setVerticalGroup(
            magPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(magPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(MagLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(magPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(magXLabel)
                    .addComponent(magXTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(magPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(magYLabel)
                    .addComponent(magYTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(magPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(magZLabel)
                    .addComponent(magZTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(magPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(magHeadLabel)
                    .addComponent(magHeadTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(12, Short.MAX_VALUE))
        );

        gpsPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        gpsLabel.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        gpsLabel.setText("GPS Data");

        gpsLongLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        gpsLongLabel.setText("Longitude:");

        gpsLatLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        gpsLatLabel.setText("Latitude:");

        gpsAltLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        gpsAltLabel.setText("Altitude:");

        gpsGndSpLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        gpsGndSpLabel.setText("Ground Speed:");

        gpsLongTxtF.setEditable(false);

        gpsLatTxtF.setEditable(false);

        gpsAltTxtF.setEditable(false);

        gpsGndSpeedTxtF.setEditable(false);

        gpsGndCourLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        gpsGndCourLabel.setText("Ground Course:");

        gpsNumSatLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        gpsNumSatLabel.setText("# Satalites:");

        gpsFixLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        gpsFixLabel.setText("Fix:");

        gpsTimeLabel.setFont(new java.awt.Font("Verdana", 3, 10)); // NOI18N
        gpsTimeLabel.setText("(UMT) Time:");

        gpsGndCourTxtF.setEditable(false);

        gpsNumSatTxtF.setEditable(false);

        gpsFixTxtF.setEditable(false);

        gpsTimeTxtF.setEditable(false);

        javax.swing.GroupLayout gpsPanelLayout = new javax.swing.GroupLayout(gpsPanel);
        gpsPanel.setLayout(gpsPanelLayout);
        gpsPanelLayout.setHorizontalGroup(
            gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(gpsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(gpsLabel)
                    .addGroup(gpsPanelLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(gpsPanelLayout.createSequentialGroup()
                                .addGroup(gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(gpsLongLabel)
                                    .addComponent(gpsLatLabel))
                                .addGap(39, 39, 39)
                                .addGroup(gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(gpsLongTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(gpsLatTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, gpsPanelLayout.createSequentialGroup()
                                    .addComponent(gpsGndSpLabel)
                                    .addGap(18, 18, 18)
                                    .addComponent(gpsGndSpeedTxtF))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, gpsPanelLayout.createSequentialGroup()
                                    .addComponent(gpsAltLabel)
                                    .addGap(48, 48, 48)
                                    .addComponent(gpsAltTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(18, 18, 18)
                        .addGroup(gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(gpsGndCourLabel)
                            .addComponent(gpsNumSatLabel)
                            .addComponent(gpsFixLabel)
                            .addComponent(gpsTimeLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(gpsTimeTxtF, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE)
                            .addComponent(gpsGndCourTxtF)
                            .addGroup(gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(gpsFixTxtF, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 22, Short.MAX_VALUE)
                                .addComponent(gpsNumSatTxtF, javax.swing.GroupLayout.Alignment.LEADING)))))
                .addContainerGap(21, Short.MAX_VALUE))
        );
        gpsPanelLayout.setVerticalGroup(
            gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, gpsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(gpsLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(gpsLongTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(gpsLongLabel)
                    .addComponent(gpsGndCourLabel)
                    .addComponent(gpsGndCourTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(gpsLatTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(gpsLatLabel)
                    .addComponent(gpsNumSatLabel)
                    .addComponent(gpsNumSatTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(gpsPanelLayout.createSequentialGroup()
                        .addGroup(gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(gpsFixTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(gpsFixLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(gpsTimeTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(gpsTimeLabel)))
                    .addGroup(gpsPanelLayout.createSequentialGroup()
                        .addGroup(gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(gpsAltLabel)
                            .addComponent(gpsAltTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(gpsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(gpsGndSpLabel)
                            .addComponent(gpsGndSpeedTxtF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout telemetryPanelLayout = new javax.swing.GroupLayout(telemetryPanel);
        telemetryPanel.setLayout(telemetryPanelLayout);
        telemetryPanelLayout.setHorizontalGroup(
            telemetryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(telemetryPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(telemetryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(telemetryPanelLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(gyrosPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(accelsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(magPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(gpsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(telemLabel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        telemetryPanelLayout.setVerticalGroup(
            telemetryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(telemetryPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(telemLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(telemetryPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(accelsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(magPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(gyrosPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(gpsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        exitButton.setText("Exit");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(controlPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(connectionsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(telemetryPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(17, Short.MAX_VALUE)
                .addComponent(telemetryPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(controlPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(connectionsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(exitButton))
                .addContainerGap())
        );
    }// </editor-fold>
    // Variables declaration - do not modify
    private javax.swing.JLabel MagLabel;
    private javax.swing.JLabel accelLabel;
    private javax.swing.JTextField accelTxtF;
    private javax.swing.JLabel accelXLabel;
    private javax.swing.JLabel accelYLabel;
    private javax.swing.JTextField accelYTxtF;
    private javax.swing.JLabel accelZLabel;
    private javax.swing.JTextField accelZTxtF;
    private javax.swing.JPanel accelsPanel;
    private javax.swing.JLabel axisXLabel;
    private javax.swing.JTextField axisXTxtF;
    private javax.swing.JLabel axisYLabel;
    private javax.swing.JTextField axisYTxtF;
    private javax.swing.JLabel axisZLabel;
    private javax.swing.JTextField axisZTxtF;
    private javax.swing.JLabel baudLabel;
    private javax.swing.JTextField baudTxtF;
    private javax.swing.JLabel connLabel;
    private javax.swing.JTextField connectedTxtF;
    private javax.swing.JPanel connectionsPanel;
    private javax.swing.JLabel controlLabel;
    private javax.swing.JPanel controlPanel;
    private javax.swing.JButton exitButton;
    private javax.swing.JLabel gpsAltLabel;
    private javax.swing.JTextField gpsAltTxtF;
    private javax.swing.JLabel gpsFixLabel;
    private javax.swing.JTextField gpsFixTxtF;
    private javax.swing.JLabel gpsGndCourLabel;
    private javax.swing.JTextField gpsGndCourTxtF;
    private javax.swing.JLabel gpsGndSpLabel;
    private javax.swing.JTextField gpsGndSpeedTxtF;
    private javax.swing.JLabel gpsLabel;
    private javax.swing.JLabel gpsLatLabel;
    private javax.swing.JTextField gpsLatTxtF;
    private javax.swing.JLabel gpsLongLabel;
    private javax.swing.JTextField gpsLongTxtF;
    private javax.swing.JLabel gpsNumSatLabel;
    private javax.swing.JTextField gpsNumSatTxtF;
    private javax.swing.JPanel gpsPanel;
    private javax.swing.JLabel gpsTimeLabel;
    private javax.swing.JTextField gpsTimeTxtF;
    private javax.swing.JLabel gyrosLabel;
    private javax.swing.JPanel gyrosPanel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel mode1Label;
    private javax.swing.JLabel magHeadLabel;
    private javax.swing.JTextField magHeadTxtF;
    private javax.swing.JPanel magPanel;
    private javax.swing.JLabel magXLabel;
    private javax.swing.JTextField magXTxtF;
    private javax.swing.JLabel magYLabel;
    private javax.swing.JTextField magYTxtF;
    private javax.swing.JLabel magZLabel;
    private javax.swing.JTextField magZTxtF;
    private javax.swing.JButton mode1Btn;
    private javax.swing.JPanel mode1Panel;
    private javax.swing.JLabel mode1RecLabel;
    private javax.swing.JTextField mode1RecTxtF;
    private javax.swing.JLabel mode1SentLabel;
    private javax.swing.JTextField mode1SentTxtF;
    private javax.swing.JButton mode2Btn;
    private javax.swing.JLabel mode2Label;
    private javax.swing.JPanel mode2Panel;
    private javax.swing.JLabel mode2RecLabel;
    private javax.swing.JTextField mode2RecTxtF;
    private javax.swing.JLabel mode2SentLabel;
    private javax.swing.JTextField mode2SentTxtF;
    private javax.swing.JButton mode3Btn;
    private javax.swing.JLabel mode3Label;
    private javax.swing.JPanel mode3Panel;
    private javax.swing.JLabel mode3RecLabel;
    private javax.swing.JTextField mode3RecTxtF;
    private javax.swing.JLabel mode3SentLabel;
    private javax.swing.JTextField mode3SentTxtF;
    private javax.swing.JButton mode4Btn;
    private javax.swing.JLabel mode4Label;
    private javax.swing.JPanel mode4Panel;
    private javax.swing.JLabel mode4RecLabel;
    private javax.swing.JTextField mode4RecTxtF;
    private javax.swing.JLabel mode4SentLabel;
    private javax.swing.JTextField mode4SentTxtF;
    private javax.swing.JLabel portLabel;
    private javax.swing.JTextField portTxtF;
    private javax.swing.JLabel telemLabel;
    private javax.swing.JPanel telemetryPanel;
    // End of variables declaration

	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void update(Observable obs, Object arg) {

		logger.info("update(" + obs + "," + arg + ");");
        if (arg instanceof TelemetryGyrosPacket) {
            tgp = (TelemetryGyrosPacket) arg;
            logger.info("update1(" + obs + "," + arg + ");");
            String aX = Integer.toString(tgp.getGyroX());
            String aY = Integer.toString(tgp.getGyroY());
            String aZ = Integer.toString(tgp.getGyroZ());
            this.axisXTxtF.setText(aX);
            this.axisYTxtF.setText(aY);
            this.axisZTxtF.setText(aZ);
            
        }else if (arg instanceof TelemetryAccelsPacket) {
            tap = (TelemetryAccelsPacket) arg;
            logger.info("update2(" + obs + "," + arg + ");");
            String accelX = Integer.toString(tap.getAccelX());
            String accelY = Integer.toString(tap.getAccelX());
            String accelZ = Integer.toString(tap.getAccelZ());
            this.accelTxtF.setText(accelX);
            this.accelYTxtF.setText(accelY);
            this.accelZTxtF.setText(accelZ);
        }else if (arg instanceof GpsPacket){
        	gpsp = (GpsPacket) arg;
        	logger.info("update3(" + obs + "," + arg + ");");
        	final String lat = Long.toString(gpsp.getLatitude());
        	final String lng = Long.toString(gpsp.getLongitude());
        	final String alt = Long.toString(gpsp.getAltitude());
        	final String gndSpeed = Long.toString(gpsp.getGroundSpeed());
        	final String gndCourse = Long.toString(gpsp.getGroundCourse());
        	final String numSats = Long.toString(gpsp.getNumSats());
        	final String fix = Long.toString(gpsp.getFix());
        	final String time = Long.toString(gpsp.getTime());
        	String utcTime = time.substring(0, 2) + ":" + time.substring(2,4) + ":" + time.substring(4,6);
        	this.gpsLatTxtF.setText(lat);
        	this.gpsLongTxtF.setText(lng);
        	this.gpsAltTxtF.setText(alt);
        	this.gpsGndSpeedTxtF.setText(gndSpeed);
        	this.gpsGndCourTxtF.setText(gndCourse);
        	this.gpsNumSatTxtF.setText(numSats);
        	this.gpsFixTxtF.setText(fix);
        	this.gpsTimeTxtF.setText(utcTime);
        
        }else if(arg instanceof MagPacket){
        	
        }else if(arg instanceof RtfPacket){
        	
        }else if(arg instanceof SerialPortStatus){
        	sps = (SerialPortStatus) arg;
        	String comPort = sps.getComPort();
        	String dataRate = Integer.toString(sps.getDataRate());
        	boolean isConnected = sps.isConnected();
        	this.portTxtF.setText(comPort);
        	this.baudTxtF.setText(dataRate);
        	this.connectedTxtF.setBackground(Color.GREEN);
        }
        
		
	}
	
	 private void Mode1BtnActionPerformed(ActionEvent evt) {
		// TODO Auto-generated method stub
		 final PacketInterface packet = PacketUtils.buildPacket("[4,0,4]");
		 
		 if(packet instanceof RtfPacket){
		     RtfPacket packetToSend = (RtfPacket) packet;
			 this.controller.sendRtfPacket(packetToSend);
		 }
	 }
	 private void mrModeBtnActionPerformed(java.awt.event.ActionEvent evt) {
	        JFrame mrModeFrame = new JFrame();
	        APHciMissionReadySwingPanel mrp = new APHciMissionReadySwingPanel(mrModeFrame);
	        mrModeFrame.add(mrp);
	        mrModeFrame.setSize(500, 600);
	        mrModeFrame.getContentPane().add(mrp);
	        mrModeFrame.setVisible(true);
	        // TODO add your handling code here:
	    }

	private void setMode1Btn(javax.swing.JButton mode1Btn) {
		this.mode1Btn = mode1Btn;
	}

	public JButton getMode1Btn() {
		return mode1Btn;
	}
	 
}

